using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace Phoenix.Frames
{
    public class ChildFrameCollection : IEnumerable<IContentFrame>
    {
        readonly ContentFrameController contentFrameController;

        public ChildFrameCollection(ContentFrameController contentFrameController)
        {
            this.contentFrameController = contentFrameController;
        }

        public IEnumerator<IContentFrame> GetEnumerator()
        {
            return contentFrameController.Children.GetEnumerator();
        }

        IEnumerator IEnumerable.GetEnumerator()
        {
            return GetEnumerator();
        }

        public IContentFrame this[string frameName]
        {
            get { return contentFrameController.Children.SingleOrDefault(f=>f.Name == frameName); }
        }
    }
}